//
//  newsViewController.m
//  OfferJob
//
//  Created by 河南动力无限科技有限公司 on 17/7/17.
//  Copyright © 2017年 郑州动力无限科技. All rights reserved.
//

#import "newsViewController.h"
#import "newsViewCell.h"


@interface newsViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong)UITableView* tableview;
@property (nonatomic,strong)NSMutableArray* newsArry;
@end

@implementation newsViewController

- (void)viewDidLoad {
    self.title=@"消息";
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    _tableview=[[UITableView alloc]initWithFrame:CGRectMake(0,0, SCREEN_WIDTH, SCREEN_HEIGHT-64)];
    _tableview.delegate=self;
    _tableview.dataSource=self;
    _tableview.backgroundColor=backgroundcolor;
    [_tableview setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    [_tableview registerClass:[newsViewCell
                               class] forCellReuseIdentifier:@"newsViewCell"];
    [self.view addSubview:_tableview];
    _newsArry=[[NSMutableArray alloc]init];
    
    [self getUserInfo];
}


// 获取
-(void)getUserInfo{
    FXTHttpRequestModel * requestModel = [[FXTHttpRequestModel alloc] init];
    requestModel.type = FXTHttpType_POST;
    requestModel.appendUrl = @"/Message/messagelist";
//    NSMutableDictionary * paramDic = [NSMutableDictionary dictionary];
//    requestModel.paramDic = paramDic;
    requestModel.callback = ^(FXTHttpResponseModel * result, NSError *error){

        if (result.state ==FXTReponseCodeState_Success) {
            NSLog(@"222333334456666%@",result.data);
            _newsArry=result.data;
            
            [_tableview reloadData];
            
        }else {
            [DisplayHelper displayWarningAlert:result.alertMsg];
        }
    };
    [[FXTHttpSessionManager sharedHttpSessionManager] sendHttpRequestParam:requestModel];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _newsArry.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSDictionary* dic=_newsArry[indexPath.row];
    newsViewCell *cell = (newsViewCell *)[tableView dequeueReusableCellWithIdentifier:@"newsViewCell" forIndexPath:indexPath];
    cell.selectionStyle=0;
    cell.titleLB.text=[NSString stringWithFormat:@"%@",[dic objectForKey:@"time"]];
     cell.nameLB.text=[NSString stringWithFormat:@"%@",[dic objectForKey:@"title"]];
     cell.conLB.text=[NSString stringWithFormat:@"%@",[dic objectForKey:@"content"]];
    
    return cell;

}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 260*kAppScale;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
